/*
 * Eugen Stoian <stoian.e@gmail.com> 2010
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#ifndef PARAMETRICOBJECT3D_H
#define PARAMETRICOBJECT3D_H
#include <QList>
#include <PlotableObject3D.h>

class Parameter;
class Expression3D;

class ParametricObject3D : public PlotableObject3D
{
    Q_OBJECT
public:
    ParametricObject3D(QObject * parent = 0);

    ParametricObject3D(const QString & expressionName, QObject * parent = 0);

    ParametricObject3D(const Expression3D * exp, QObject * parent = 0);

    virtual ~ParametricObject3D();

    void setExpression(const QString & expressionName);

    void setExpression(const Expression3D * exp);

    const Expression3D * expression() const;

    QList< Parameter * > & parameters();

    const QList< Parameter * > & parameters() const;

    QList<const Parameter*> fixedParameters() const;

    QList<Parameter*> fixedParameters();

    QList<const Parameter*> autoParameters() const;

    QList<Parameter*> autoParameters();

    void updateParameter(const Parameter* param);

    virtual Object* clone() const = 0;

    virtual bool isValid() const;

    virtual bool isEmpty() const;

    friend QDataStream& operator<<(QDataStream& stream, const ParametricObject3D& c);

    friend QDataStream& operator>>(QDataStream& stream, ParametricObject3D& c);

public slots:
    virtual void compute() = 0;

protected slots:
    void onExpressionDestroyed();

protected:
    virtual void cleanUp();

protected:
    const Expression3D* _expression;
    QList<Parameter*> _parameters;
};


QDataStream& operator<<(QDataStream& stream, const ParametricObject3D& c);

QDataStream& operator>>(QDataStream& stream, ParametricObject3D& c);

#endif // PARAMETRICOBJECT3D_H
